/**
 * 表结构初始化
 */

const { Sequelize, Model } = require('sequelize')
const { sequelize } = require('@core/db.js')
const { Goods } = require('./goods')

class Category extends Model {

}

Category.init({
  id: {
    type: Sequelize.INTEGER,
    primaryKey: true,
    autoIncrement: true
  },
  name: Sequelize.STRING
}, {
  sequelize,
  // indexes: [{ fields: ['id'] }],
  tableName: 'category'
})

// Category.belongsTo(Goods, { foreignKey: 'category_id', targetKey: 'id' })
// Category.belongsTo(Goods, { as: 'Goods', foreignKey: 'id' })

module.exports = {
  Category
}